#include <stdio.h>
#include <SDL2/SDL.h>

int main(int argc, char *argv[])
{
    SDL_Window *window = NULL;
    int quit = 1;
     SDL_Renderer *render;
    SDL_Init(SDL_INIT_VIDEO);
    window = SDL_CreateWindow("YUANXUZHEN",
                              100,
                              100,
                              480,
                              320,
                              SDL_WINDOW_SHOWN);
    // window = SDL_CreateWindow("Hello world", 500, 500, 640, 480, SDL_WINDOW_SHOWN);


    if (!window)
    {
        printf("create window fail\n");
        goto __EXIT;
    }

    render = SDL_CreateRenderer(window, -1, 0);
    if (!render)
    {
        printf("create render fail\n");
        goto __EXIT;
    }
    SDL_SetRenderDrawColor(render, 255, 0, 0, 255);
    SDL_RenderClear(render);
    SDL_RenderPresent(render);
    do
    {
        SDL_Event event;
        SDL_WaitEvent(&event);
        switch (event.type)
        {
        case SDL_QUIT:
            quit = 0;
            break;

        default:
             printf("EVENT TYPE %d\n", quit);
            break;
        }
    } while (quit);
__EXIT:
    if(render){
        SDL_DestroyRenderer(render);
    }

    if(window){
        SDL_DestroyWindow(window);
    }

    SDL_Quit();
    return 0;
}